let uu = document.querySelector('.uu')
let foot = document.querySelector('.footer1>div>b:nth-of-type(3)')
let span = document.querySelector('span')
let xdv = document.querySelector('.uuu>li>div:nth-of-type(2)')
fetch('http://chst.vip:1234/api/getbaicaijiatitle')
    .then(body => body.json())
    .then(res => {
        render(res.result, uu)
    })
function render(data, el) {
    let domStr = ""
    data.forEach(item => {
        domStr += `<li titleid=${item.titleId}> ${item.title}</li>`
        el.innerHTML = domStr
    })
}
uu.onclick = function (e) {
    $(this).siblings('.uuu').find('li').css('display', 'none')
    if (e.target.localName === 'li') {
        let _this = e.target
        let titleid = _this.getAttribute('titleid')
        titleid = Number(titleid)
        fetch('http://chst.vip:1234/api/getbaicaijiaproduct?titleid=' + titleid)
            .then(body => body.json())
            .then(res => {
                console.log(res)
                let listArr = res.result
                listArr.forEach(item => {
                    let li = document.createElement('li')
                    let dv = document.createElement('div')
                    let xdv = document.createElement('div')
                    let domStr = `<img src="../images/4.png"><b>${item.productName}</b>
                        <b>${item.productPrice}</b><b>立即抢购</b>`
                    li.innerHTML = domStr
                    li.appendChild(dv)
                    li.appendChild(xdv)
                    uuu.appendChild(li)
                })
                $('li').find('div:eq(1)').animate({ width: 2.6667 + 'rem' }, 2000)

            })
    }
}
let uuu = document.querySelector('.uuu')
fetch('http://chst.vip:1234/api/getbaicaijiaproduct?titleid=0')
    .then(body => body.json())
    .then(res => {
        console.log(res)
        renders(res.result, uuu)

    })
function renders(data, el) {
    data.forEach(item => {
        let li = document.createElement('li')
        let domStr = `<img src="../images/4.png"><b>${item.productName}</b>
            <b>${item.productPrice}</b><b>立即抢购</b><div></div><div>100%</div>`
        li.innerHTML = domStr
        el.appendChild(li)
        $('li').find('div:eq(1)').animate({ width: 2.6667 + 'rem' }, 3000)
    })

}
span.onclick = function () {
    location.href = "./../index.html"
}
foot.onclick = function () {
    location.href = "./../index.html"
}